package cz.spock.core.entity.acl;

import javax.persistence.Entity;
import javax.persistence.Id;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cached;

import cz.spock.core.entity.Account;

/**
 * stores default access rights
 * 
 * each entity is supposed to have default access rights
 * 
 * owner of entity has all rights
 * 
 * super user has all rights
 * 
 * rights are stored as integer representation of binary value RWD (read, write, delete)
 * - 0 = no rights 000
 * - 1 = delete only 001
 * - 2 = write only 010
 * - 3 = write and delete 011
 * - 4 = read only 100
 * - 5 = read and delete 101
 * - 6 = read and write 110
 * - 7 = read, write, delete 111
 * * new rights can be simple added
 * 
 * @author miso
 *
 */
@Entity
@Cached
public class AclDefault {

    @Id
    private Long id;    
    private Key entity;
    private int rights;
    private Key<Account> owner;
    
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Key getEntity() {
        return entity;
    }
    public void setEntity(Key entity) {
        this.entity = entity;
    }
    public int getRights() {
        return rights;
    }
    public void setRights(int rights) {
        this.rights = rights;
    }
    public Key<Account> getOwner() {
        return owner;
    }
    public void setOwner(Key<Account> owner) {
        this.owner = owner;
    }
    
}
